package com.common.util;

import com.system.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @Classname ProbjectUtils
 * @Date 2023/7/31 15:21
 * @Created ZFC
 */
@Component
@Slf4j
public class ProbjectUtils {

    @Autowired
    private CacheManager cacheManager;

    @Autowired
    RedisTemplate redisTemplate;

    /**
     * 清空项目中的所有缓存，除了验证码
     */
    @Async
    public void clearAllCache(String username){
        log.info("【退出登录】-异步执行清空缓存:",username);
        if (StringUtils.isNotEmpty(username)){
            redisTemplate.delete(username);
        }

    }
}
